package com.edu.juc.lock;

public class DeadLock {
    public static void main(String[] args) {
        Object A = new Object();
        Integer B = 1;
        new Thread(() -> {
            synchronized (A) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (B) {
                    System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName());
                }
            }
        }, "A").start();
        new Thread(() -> {
            synchronized (B) {
                synchronized (A) {
                    System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName());
                }
            }
        }, "B").start();
    }
}
